package com.liuyk.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import com.liuyk.main.activity.R;

/**
 * 换肤
 * <p>
 * Created by Administrator on 2019/11/25.
 */
public class SkinActivity extends Activity {
    private static final String TAG = "BaseMain";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        LayoutInflater.from(this).setFactory2(new LayoutInflater.Factory2() {
            @Override
            public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
                if (TextUtils.equals(name, "TextView")) {
                    Button button = new Button(SkinActivity.this);
                    button.setText("我是Button，换掉了TextView");
                    return button;
                }
                return null;
            }

            @Override
            public View onCreateView(String name, Context context, AttributeSet attrs) {
                return null;
            }
        });
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_skin);
        Log.i(TAG, "Skin onCreate");
    }


    @Override
    protected void onStart() {
        super.onStart();
        Log.i(TAG, "Skin onStart");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i(TAG, "Skin onRestart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.i(TAG, "Skin onResume");
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i(TAG, "Skin onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i(TAG, "Skin onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "Skin onDestroy");
    }
}
